<template>
  <div class="chat-box">
    <input type="text" placeholder="输入消息..." v-model="chatMessage" @keyup.enter="sendMessage" />
    <button @click="sendMessage">发送</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      chatMessage: '',
    };
  },
  methods: {
    sendMessage() {
      if (this.chatMessage.trim() !== '') {
        this.$emit('send', this.chatMessage);
        this.chatMessage = '';
      }
    },
  },
};
</script>

<style scoped>
.chat-box {
  display: flex;
  padding: 10px;
  background-color: #fff;
  border-top: 1px solid #f0f0f0;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  margin-top: 15px;
}

input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 5px;
  margin-right: 10px;
  font-size: 14px;
}

button {
  padding: 8px 15px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
}

button:hover {
  background-color: #0056b3;
}
</style>
